<!DOCTYPE html>  
<html lang="en">  
<head>  
    <meta charset="UTF-8">  
    <meta name="viewport" content="width=device-width, initial-scale=1.0">  
    <title>修改密码</title>  
    <script src="/static/js/jquery.min.js"></script>
    <style>  
        /* 基础样式 */  
        body {  
            font-family: Arial, sans-serif;  
            margin: 0;  
            padding: 20px;  
            background-color: #f5f5f5;  
            color: #333;  
        }  
  
        /* 表单容器 */  
        .form-container {  
            position: absolute;
            left: 50%;
            top: 30%;
            margin-left:-200px;
            width: 400px;  
            background-color: #fff;  
            padding: 20px;  
            border-radius: 5px;  
            box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);  
        }  
  
        /* 表单标题 */  
        .form-container h2 {  
            text-align: center;  
            margin-bottom: 20px;  
        }  
  
        /* 表单项 */  
        .form-container label {  
            display: block;  
            margin-bottom: 5px;  
        }  
  
        .form-container input[type="password"],  
        .form-container input[type="button"] {  
            width: 100%;  
            padding: 10px;  
            border-radius: 5px;  
            border: 1px solid #ccc;  
            box-sizing: border-box;  
        }  
  
        /* 提交按钮 */  
        .form-container input[type="button"] {  
            background-color: #4CAF50;  
            color: white;  
            cursor: pointer;  
            margin-top: 10px;  
        }  
  
        /* 提交按钮点击效果 */  
        .form-container input[type="button"]:hover {  
            background-color: #45a049;  
        }  
  
        /* 错误消息（如果需要的话） */  
        .error-message {  
            color: red;  
            margin-top: 5px;  
        }  
    </style>  
</head>  
<body>  
    <div class="form-container">  
        <h2>修改密码</h2>  
        <!-- <form action="/change-password" method="post">   -->
            <label for="newPassword">新密码:</label>  
            <input type="password" id="password" name="newPassword" required>  
  
            <label for="confirmPassword">确认密码:</label>  
            <input type="password" id="pwd" name="confirmPassword" required>  
  
            <!-- 如果有需要，可以添加错误消息显示 -->  
            <!-- <p class="error-message">密码不匹配或不符合要求</p> -->  
  
            <input type="button" onclick="save_password()" value="修改密码">  
        <!-- </form>   -->
    </div>  
</body>  
<script>
    function save_password(){
        let password = document.getElementById('password').value,pwd = document.getElementById('pwd').value;
        if(password != pwd)
            return alert('两次密码输入不一致');
        console.log(password);
        $.ajax({
            url: '/index/user/password', // 你的 PHP 脚本的 URL  
                type: 'post', // 请求类型，可以是 'GET' 或 'POST'  
                dataType: 'json', // 预期服务器返回的数据类型  
                data: {password:password},
                success: function(res) { 
                    if(res.code == 200){
                       location.href = '/index/out'; 
                    }else{
                        return alert(res.msg);
                    }
                }
        });
    }
</script>
</html>